<?php
namespace Home\Controller;
use Think\Controller;
header("Content-type:text/html;charset=utf-8");
class CaseController extends BaseController {
 //    public function anjian(){
 //    	//考核年月
	// 	// $mtime = $_POST['mtime'];
	// 	$mtime = "2017-10";
	// 	$mtime1 = explode('-', $mtime);
	// 	//年
	// 	$year = $mtime1['0'];
	// 	//月
	// 	$month = $mtime1['1'];
	// 	if ($month =='02' ) {
	// 		if ($year % 4 == 0 && $year % 100 !=0 || $year % 400 ==0) {
	// 			$time = strtotime($mtime) + '2505599';//29
	// 		}else{
	// 			$time = strtotime($mtime) + '2419199';//28
	// 		}
	// 	}elseif ($month =='04' || $month =='06' || $month =='09' || $month =='11') {
	// 		$time = strtotime($mtime) + '2591999';//30
	// 	}else{
	// 		$time = strtotime($mtime) + '2678399';//31
	// 	}
	// 	//考核人员
	// 	$worker_id = session('worker_id');
	// 	$wk = M('worker')->where('worker_id='.$worker_id)->find();
	// 	$worker = $wk['worker_name'];
	// 	// var_dump($worker);die;
	// 	$map['worker'] = array('like',$worker);
	// 	$map['stime'] = array('elt',$time);
	// 	//全部案件
	// 	$channel = M('channel')->where($map)->select();
	// 	// var_dump($channel);die;
	// 	foreach($channel as $k => $v){
	// 		if($v['stime'] == ''){
	// 			unset($channel[$k]);
	// 		}else{
	// 			//已结案件
	// 			$channel1[] = $v;
	// 		}
	// 	}
	// 	// echo "<pre>";
	// 	// var_dump($channel1);
	// 	// echo "</pre>";die;
	// 	$number1 = count($channel);
	// 	$number2 = count($channel1);
	// 	$number3 = $number1 -$number2;

	// 	$this->assign('worker_id',$worker_id);
	// 	$this->assign('list',$channel);
	// 	$this->assign('number1',$number1);
	// 	$this->assign('number2',$number2);
	// 	$this->assign('number3',$number3);
	// 	$this->display();
		
	// }

	/*
		审判管理-案件管理
	 */
	public function anjian(){
		if(IS_POST){
			// 按年份查看案件ajax请求
			$id = $_POST['id'];
			$notes = M('notes')->where('id='.$id)->find();
			$year = date('Y',$notes['ktime']);
			$time1 = $year . '-' . '12';
			$time = strtotime($time1) + 2678399;

			$worker_id = session('worker_id');
			$wk = M('worker')->where('worker_id='.$worker_id)->find();
			$worker = $wk['worker_name'];
			// var_dump($worker);die;

			$map['worker'] = array('like',$worker);
			$map['ktime'] = array('elt',$time);
			//显示所有的数据
			$map['worker'] = array('like',$worker);
			$map['ktime'] = array('elt',$time);
			$channel = M('channel')->where($map)->order('ktime asc')->select();
			// var_dump($channel);die;
			foreach($channel as $k => $v){
				if($v['stime'] == ''){
					unset($channel[$k]);
				}else{
					//已结案件
					$channel1[] = $v;
				}
			}
			// echo "<pre>";
			// var_dump($channel1);
			// echo "</pre>";die;
			$number1 = count($channel);
			$number2 = count($channel1);
			$number3 = $number1 -$number2;

			$this->assign('worker_id',$worker_id);			
			$this->assign('list',$channel);
			$this->assign('notes',$notes);
			$this->assign('number1',$number1);
			$this->assign('number2',$number2);
			$this->assign('number3',$number3);
			$this->display('anjian1');	
		}else{
			$notes = M('notes')->order('ktime desc')->select();
			$year = date('Y',$notes['0']['ktime']);
			$time1 = $year . '-' . '12';
			$time = strtotime($time1) + 2678399;

			$worker_id = session('worker_id');
			$wk = M('worker')->where('worker_id='.$worker_id)->find();
			$worker = $wk['worker_name'];
			// var_dump($worker);die;
			
			// 默认显示所有的数据
			$map['worker'] = array('like',$worker);
			$map['ktime'] = array('elt',$time);
			$channel = M('channel')->where($map)->order('ktime asc')->select();
			// var_dump($channel);die;
			foreach($channel as $k => $v){
				if($v['stime'] == ''){
					unset($channel[$k]);
				}else{
					//已结案件
					$channel1[] = $v;
				}
			}
			// echo "<pre>";
			// var_dump($channel1);
			// echo "</pre>";die;
			$number1 = count($channel);
			$number2 = count($channel1);
			$number3 = $number1 -$number2;

			$this->assign('worker_id',$worker_id);			
			$this->assign('list',$channel);
			$this->assign('notes',$notes);
			$this->assign('number1',$number1);
			$this->assign('number2',$number2);
			$this->assign('number3',$number3);
			$this->display();
		}
	}

	
	
}